package com.foodorder.entity;

import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

/**
 * 商品评价实体类
 */
@Data
@Entity
@Table(name = "reviews")
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Review {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 订单ID
     */
    @Column(nullable = false)
    private Long orderId;

    /**
     * 用户ID
     */
    @Column(nullable = false)
    private Long userId;

    /**
     * 商品ID
     */
    @Column(nullable = false)
    private Long productId;

    /**
     * 商店ID
     */
    @Column(nullable = false)
    private Long storeId;

    /**
     * 评分(1-5)
     */
    @Column(nullable = false)
    private Integer rating;

    /**
     * 评论内容
     */
    @Column(length = 1000)
    private String content;

    /**
     * 评价图片，最多9张，JSON数组格式存储图片URL
     */
    @Column(length = 1000)
    private String images;

    /**
     * 是否匿名评价
     */
    private Boolean anonymous;

    /**
     * 商家回复
     */
    @Column(length = 500)
    private String reply;

    /**
     * 商家回复时间
     */
    private LocalDateTime replyTime;

    /**
     * 评价标签，JSON数组格式存储
     */
    @Column(length = 255)
    private String tags;

    /**
     * 点赞数
     */
    private Integer likes;

    /**
     * 是否显示
     */
    private Boolean display;

    /**
     * 创建时间
     */
    @CreationTimestamp
    private LocalDateTime createdAt;

    /**
     * 更新时间
     */
    @UpdateTimestamp
    private LocalDateTime updatedAt;

    /**
     * 评价类型
     */
    @Enumerated(EnumType.STRING)
    private ReviewType type;

    /**
     * 评价类型枚举
     */
    public enum ReviewType {
        /**
         * 商品评价
         */
        PRODUCT,
        
        /**
         * 订单评价
         */
        ORDER,
        
        /**
         * 配送评价
         */
        DELIVERY
    }
} 